//
//  YCFriendSmartCollectionViewCell.m
//  YCSchool
//
//  Created by gmall on 16/5/12.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  智能推荐(好友卡片)

#import "YCFriendSmartCollectionViewCell.h"

@interface YCFriendSmartCollectionViewCell()

@property (nonatomic, readonly) CGFloat fontSize;//大小

@end

@implementation YCFriendSmartCollectionViewCell


- (instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [YCAdapter performOtherBlock:^{
            _fontSize = 15;
        } IPhone6Block:^{
            _fontSize = 16.5;
        } IPhone6pBlock:^{
            _fontSize = 17.5;
        }];
        
        _bg = [[UIView alloc] init];
        _bg.backgroundColor = [UIColor whiteColor];
        _bg.layer.cornerRadius = 6;
        _bg.clipsToBounds = YES;
        [self.contentView addSubview:_bg];
        
        _iconImage = [[UIImageView alloc]init];
        _iconImage.clipsToBounds = NO;
        _iconImage.contentMode = UIViewContentModeScaleAspectFill;
        _iconImage.layer.cornerRadius = 70 / 2.0;
        _iconImage.layer.masksToBounds = YES;
        _iconImage.userInteractionEnabled = YES;
        [self.bg addSubview:_iconImage];
        
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.font = [UIFont systemFontOfSize:_fontSize];
        _nameLabel.textColor = [UIColor blackColor];
        _nameLabel.textAlignment = NSTextAlignmentCenter;
        [self.bg addSubview:self.nameLabel];
        
        _addressLabel = [[UILabel alloc] init];
        _addressLabel.font = [UIFont systemFontOfSize:12];
        _addressLabel.textColor = [UIColor lightGrayColor];
        _addressLabel.textAlignment = NSTextAlignmentCenter;
        [self.bg addSubview:self.addressLabel];
        
        [_bg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.and.left.right.equalTo(self.contentView);
        }];
        
        [_iconImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(_bg);
            make.top.equalTo(self.bg).offset(10);
            make.height.width.equalTo(@70);
        }];
        
        [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_iconImage.mas_bottom).offset(5);
            make.left.right.equalTo(_bg);
        }];
        
        [_addressLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLabel.mas_bottom).offset(5);
            make.left.right.equalTo(_bg);
        }];
    }
    return self;
}

@end
